package manager

import (
	"time"

	"gitcode.com/G-YT/baoyou/server/model/system"
	"gorm.io/datatypes"
	"gorm.io/gorm"
)

type Login interface {
	GetHmId() uint
	GetName() string
	GetPhone() string
	GetAuthorityId() uint
}

var _ Login = new(HealthManager)

// HealthManager 健管师结构体
type HealthManager struct {
	CreatedAt           time.Time       // 创建时间
	UpdatedAt           time.Time       // 更新时间
	DeletedAt           gorm.DeletedAt  `gorm:"index" json:"-"`                                                                                                           // 删除时间
	HmID                uint            `json:"hmID" form:"hmID" gorm:"column:hm_id;comment:;size:19;primarykey;AUTO_INCREMENT;"`                                         // hmId字段
	ServiceStationID    uint            `json:"serviceStationID" form:"serviceStationID" gorm:"column:service_station_id;comment:服务站ID;size:10;"`                         // 服务站ID
	ServiceStation      *system.SysUser `json:"serviceStation" form:"-" gorm:"->;foreignKey:ServiceStationID;references:ID;"`                                             // 服务站关联信息
	Phone               string          `json:"phone" form:"phone" gorm:"column:phone;comment:手机号/账号;size:191;"`                                                          //手机号/账号
	IDNumber            string          `json:"IDNumber" form:"IDNumber" gorm:"column:IDNumber;comment:身份证号;size:191;"`                                                   // 身份证号
	Password            string          `json:"password" form:"password" gorm:"column:password;comment:密码;size:191;"`                                                     //密码
	Name                string          `json:"name" form:"name" gorm:"column:name;comment:名称;size:191;"`                                                                 //名称
	Sex                 *int            `json:"sex" form:"sex" gorm:"column:sex;default:1;comment:性别 1男 2女;"`                                                             //性别 1男 2女
	PromoteNum          *int            `json:"promoteNum" form:"promoteNum" gorm:"column:promote_num;default:0;comment:推广人数;size:19;"`                                   //推广人数
	Grade               uint            `json:"grade" form:"grade" gorm:"column:grade;comment:等级 1初级 2中级 3高级;size:19;default:1"`                                          //等级 1初级 2中级 3高级
	ServedNum           *int            `json:"servedNum" form:"servedNum" gorm:"column:served_num;default:0;comment:服务人数;size:19;"`                                      //服务人数
	Avatar              string          `json:"avatar" form:"avatar" gorm:"column:avatar;comment:头像;size:191;"`                                                           // 头像
	Score               uint            `json:"score" form:"score" gorm:"column:score;comment:评分;size:19;"`                                                               //评分
	Level               int             `json:"level" form:"level" gorm:"column:level;comment:等级;size:19;"`                                                               //等级 0初级 1中级 2高级
	OpenNum             uint            `json:"openNum" form:"openNum" gorm:"column:open_num;default:0;comment:开通数量;size:19;"`                                            // 授权开通数量
	CertificationStatus uint            `json:"certificationStatus" form:"certificationStatus" gorm:"column:certification_status;default:0;comment:认证状态 0未认证 1已认证 2已驳回;"` //认证状态 0未认证 1已认证 2已驳回
	CertificationImages datatypes.JSON  `json:"certificationImages" form:"certificationImages" gorm:"column:certification_images;comment:认证证书（多图JSON）;"`                  // 认证证书（多图）
	CertificationNo     string          `json:"certificationNo" form:"certificationNo" gorm:"column:certification_no;comment:认证编号;size:191;"`                             // 认证编号
	Type                uint            `json:"type" form:"type" gorm:"column:type;default:0;comment:健管师类型 0普通 1会员 2过期会员;"`                                               // 健管师类型
	RegisterStatus      uint            `json:"registerStatus" form:"registerStatus" gorm:"column:register_status;default:0;comment:注册状态 0申请中 1已通过 2已驳回;"`                //注册状态 0申请中 1已通过 2已驳回
	RegisterInfo        string          `json:"registerInfo" form:"registerInfo" gorm:"column:register_info;comment:注册信息;"`                                               // 注册信息
	Code                string          `json:"code" form:"code" gorm:"-"`
}

// TableName 健管师表 HealthManager自定义表名 by_health_manager
func (HealthManager) TableName() string {
	return "by_health_manager"
}

func (h *HealthManager) GetHmId() uint {
	return h.HmID
}

func (h *HealthManager) GetName() string {
	return h.Name
}

func (h *HealthManager) GetPhone() string {
	return h.Phone
}

func (h *HealthManager) GetAuthorityId() uint {
	return 666
}
